package com.balance.anole.client.retail.payment;

import java.math.BigDecimal;

import com.balance.anole.common.to.CodeLookTO;
import com.balance.anole.erp.util.NumberUtil;

public abstract class Payment {

	protected BigDecimal paid;

	protected BigDecimal needPay;

	protected CodeLookTO paymentMode;

	protected String paymentValidationMsg;

	public String getPaymentValidationMsg() {
		return paymentValidationMsg;
	}

	public void setPaymentValidationMsg(String paymentValidationMsg) {
		this.paymentValidationMsg = paymentValidationMsg;
	}

	public BigDecimal getPaid() {
		return paid;
	}

	public void setPaid(BigDecimal paid) {
		this.paid = paid;
	}

	public BigDecimal getNeedPay() {
		return needPay;
	}

	public void setNeedPay(BigDecimal needPay) {
		this.needPay = needPay;
	}

	public void setPaymentMode(CodeLookTO paymentMode) {
		this.paymentMode = paymentMode;
	}

	public CodeLookTO getPaymentMode() {
		return paymentMode;
	}

	public Payment(BigDecimal paid, BigDecimal needPay) {
		this.paid = paid;
		this.needPay = needPay;
	}

	public abstract int getPriority();

	public abstract BigDecimal pay();

	public abstract String getPaymentDesc();

	public boolean isValid(){
		if(NumberUtil.isTinyMoney(needPay) && ! NumberUtil.isTinyMoney(paid)){
//			setPaymentValidationMsg("No need to pay (" + NumberUtil.formatMoney(paid) + ") by " + getPaymentDesc() + ".");
			setPaymentValidationMsg("款项 " + getPaymentDesc() + " 金额  " + NumberUtil.formatMoney(paid) + " 需要清除.");
			return false;
		}
		return true;
	}

	public abstract BigDecimal getRealPaidValue();

}
